package GUI;
/**
 * parent user type main menu
 */

import java.awt.Dimension;
import java.io.IOException;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JComboBox;

import Common.StudentClass;


public class ParentMainMenu extends JFrame 
{
	private JMenuBar menuBar = null;
	private JMenu menu = null;
	private JMenuItem menuItem = null;
	//private JFrame ParentMainMenu=null;
	public static Dimension defaultDim ;
	private JMenuItem logout = null;
	public Login myLoginFrame = null;
	public UserParent user=null;// my add
	public ParentViewPersonalData pViewPD=null;
	public SelectStudentForParent pSelStud=null;
	private int numOfChildren=100;
	private ParentViewCheckedAssignmentScreen viewCheckedAssignmentScr=null;
	private EmptyScr emptyScr = null;
	
	
	private JMenuBar createMenuBar()
	{
		if (menuBar==null)
		{
			menuBar = new JMenuBar();
			menu = new JMenu("Personal data");
			menuItem = new JMenuItem("View personal data");
			menuItem.addActionListener(new java.awt.event.ActionListener()
			{	
				public void actionPerformed(java.awt.event.ActionEvent e)
			
				{
					System.out.println("mntmParentViewPersonalData");
					
					System.out.println(numOfChildren);
					System.out.println(user.numOfChildren);
					pSelStud = null;
					pSelStud=getSelStudentScreen();
					pSelStud.myLoginFrame=myLoginFrame;
				//	pViewPD=getParentViewPersonalDataPanel();
				//	pViewPD.myLoginFrame=myLoginFrame;
					setContentPane(pSelStud);
					
					
					
				
					//else
						
					//setContentPane(pViewPD);
					//if(user.numOfChildren>0)
					
					}
		});
			
			
			logout = new JMenuItem("Logout");
			  logout.addActionListener(new java.awt.event.ActionListener()
				{	
					public void actionPerformed(java.awt.event.ActionEvent e)
				
					{
						System.out.println("logout");
						if(myLoginFrame.LoginResult.equalsIgnoreCase("OK"))
						{
							myLoginFrame.client.handleMessageFromClientUI("logout "+myLoginFrame.UserName.getText().toString());
						}
						myLoginFrame.UserName.setText("");
						myLoginFrame.Password.setText("");
						myLoginFrame.setContentPane(myLoginFrame.getFirstPanel());
						myLoginFrame.setVisible(true);
						myLoginFrame.LoginResult=null;
						myLoginFrame.UserType=null;
						setVisible(false);
						
						
						
						
				}
			});
		
		
			
		}
	
		
		return menuBar;
	}
	
	private void initialize()
	{
		
		this.setSize(defaultDim=new Dimension(600,600));
		this.setTitle("Parent main menu");
		
		this.setJMenuBar(createMenuBar());
		menuBar.add(menu);
		menu.add(menuItem);
		//menuBar.add(getSelStudentCb(user.StudentsData));
		menuBar.add(logout);
		
	}
	
	public ParentMainMenu()
	{
     super();
     initialize();
		
	}
	
	
	public ParentViewPersonalData getParentViewPersonalDataPanel()
	{
		if(pViewPD==null)
		{
			pViewPD = new ParentViewPersonalData(this);
			pViewPD.myLoginFrame=this.myLoginFrame;
			pViewPD.user=this.user;
			pViewPD.setSize(getMaximumSize());
			pViewPD.setLayout(null);
			pViewPD.pmn=this;
			
		}
		return pViewPD;
		
	}
	
	public SelectStudentForParent getSelStudentScreen()
	{
		if(pSelStud==null)
		{
			pSelStud = new SelectStudentForParent(this);
			pSelStud.myLoginFrame=this.myLoginFrame;
			pSelStud.user=this.user;
			pSelStud.setSize(getMaximumSize());
			pSelStud.setLayout(null);
			pSelStud.pmn=this;
			
		}
		return pSelStud;
	}
	
	public void setNumOfChildren(int num)
	{
		numOfChildren=num;
	}
	
	public ParentViewCheckedAssignmentScreen getCheckedAssignmentScr()
	{
		if(viewCheckedAssignmentScr==null)
		{
			viewCheckedAssignmentScr = new ParentViewCheckedAssignmentScreen(this);
		
			viewCheckedAssignmentScr.myLoginFrame=this.myLoginFrame;
			viewCheckedAssignmentScr.user=this.user;
			viewCheckedAssignmentScr.pmn=this;
			viewCheckedAssignmentScr.setSize(getMaximumSize());
			
		}
		return viewCheckedAssignmentScr;
	
	
	}
	public EmptyScr getEmptyScr()
	{
		if(emptyScr==null)
		{
			emptyScr = new EmptyScr();
			emptyScr.setSize(getMaximumSize());
		}
		return emptyScr;
		
	}
}
